<?php
/**
 * 
 */

/**
 * 
 */
require_once('User.php');
require_once('InvalidUserException.php');
/**
 * Handles all created instances of the users in an easy to use class (Caching)
 * API-Like: $project_identifier used instead of internals etc etc
 * @author Anthony Free
 * @package eclipsemde
 * @subpackage core
 */
class UserStash extends StashMap {    
    /**
     * Constructor for the userstash class
     * @since 20120716
     */
    protected function SingletonConstruct() {}
    
    /**
     * Destructor for user stash class 
     */
    public function __destruct() {}

    /**
     * Get Method, returns a User Instance
     * @param type $identifier
     * @return User
     * @throws InvalidUserException 
     */
    public function get($identifier) {
	try {
	    return parent::get($identifier);
	} catch(StashMapException $e) {
	    throw new InvalidUserException("Caused by ".$e->getMessage());
	    return false;
	}
    }
    
    /**
     * Stash method, returns a User Instance
     * @param type $identifier
     * @param type $force_restash
     * @return User
     * @throws InvalidUserException 
     */
    public function stash($identifier, $force_restash = false) {
	try {
	    return parent::stash($identifier, 'User', $force_restash);
	} catch(StashMapException $e) {
	    throw new InvalidUserException("Caused by ".$e->getMessage());
	    return false;
	}
    }
    
}
$UserStash = Singleton::CreateInstance('UserStash');
?>